//
//  Helper.swift
//  HisPaste
//
//  Created by 烟雀 on 2024/2/16.
//

import Foundation
import SwiftUI
import ApplicationServices


class AppHelper{
    static let openAccessSymbol = "open 'x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility'"
    
    static func openAccessSettings(){
        _ = ShellCommand.exec(cmds: ["-c", openAccessSymbol])
    }
    
    static func exit_(){
        NSApp.terminate(self)
        // NSApplication.shared.terminate(self)
    }
    
    static func restart(){
        Process.launchedProcess(launchPath: "/usr/bin/open", arguments: ["-b", Bundle.main.bundleIdentifier!])
        // NSApp.terminate(self)
        exit_()
    }
    
    static func hasAccess() -> Bool{
        return AXIsProcessTrusted()
    }
    
}

